/**
 * Created by mengxiaxia on 2017/1/15.
 */
(function () {
    var app=angular.module('app', ['ui.router']);
    app.config(["$stateProvider","$urlRouterProvider",routeConfig]);
    app.controller("testCtrl", angular.noop);

    /** 路由设置 **/
    function routeConfig($stateProvider,$urlRouterProvider){
        $urlRouterProvider.otherwise("/home");
        $stateProvider
            .state("home",{
                url:"/home",
                controller: 'HomeController', //也可以写成HomeController as home
                controllerAs: 'home',
                templateUrl:"'home.html'"
            })
            .state("schools",{
                url:"/schools",
                templateUrl:"'allSchools.html'"
            })
            .state("classrooms",{
                url:"/classrooms",
                templateUrl:"'allClassrooms.html'"
            })
            .state("activities",{
                url:"/activities",
                templateUrl:"'allActivities.html'"
            })
    }

    app.controller('HomeController', [ '$state','$log', HomeController]);
    function HomeController($state,$log) {
        var vm = this;
        vm.message = 'Welcome to School Buddy【'+Math.random()+'】';
        //使用$state服务
        vm.refresh = function(){
            $log.debug($state.current);
            $state.reload();
        }
    }
})();